#ifndef MPLAYERWRAPPER_H
#define MPLAYERWRAPPER_H

#include <QObject>
#include <QProcess>
#include <QTimer>
#include <QDebug>
#include <QByteArray>
#include <QWidget>
#include <QMdiSubWindow>
/*
  enveloppe pour le lecteur de video
*/

class MPlayerWrapper : public QObject
{
    Q_OBJECT

public:
    explicit MPlayerWrapper(QString home, QObject *parent=0);
    ~MPlayerWrapper();
    void setEmbeeder(QWidget * w);

signals:
    void started(int lengthSeconds,double resolution);
    void positionNofify(double positionRelative);
    void videoFinished(int exitCode);
    void failedToStart(QString desc);
    void failed(QString desc);
    void playing();
    void pausing();

public slots:
    void playVideo(QString type,QString vId);
    void pause();
    void relativeSeek(int seconds);


private slots:
    void readyToRead();
    void readyToReadError();
    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
    void refreshPosition();

private:
     QProcess *innerProcess;
     double length;
     double aspect;
     QTimer *refreshTimer;

     QWidget *embeeder;
     QString kDeadMouseHome;
     QString nextIdToPlay;
     QString nextTypeToPlay;

     void sendOrder(QString line);
     void playNextVideo();
     void onLaunched();
};

#endif // MPLAYERWRAPPER_H
